import ExeApi from "../utils/communicate/post.api";

const CryptoJS = require('crypto-js');
const encryptByDESModeCBC = (message, key) => {
    var keyHex = CryptoJS.enc.Utf8.parse(key);
    var encrypted = CryptoJS.DES.encrypt(message, keyHex, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.ZeroPadding,
    });
    return encrypted.ciphertext.toString();
};

const publicApi = {
    //用户登录
    Login: data => { 
        let timer = new Date().valueOf();
        data.request_period = String(timer); // 时间戳
        data.user_passwd = encryptByDESModeCBC(data.user_passwd, timer);
        return ExeApi(data, 'us_UserLoginInAction.do'); 
    },
    //用户退出
    Signout: data => { return ExeApi(data, 'us_UserLogoutAction.do'); },
    //修改密码
    Modify: data => { return ExeApi(data, 'us_UpdatePwdAction.do'); },
    //获取菜单资源
    GetMenus: data => { return ExeApi(data, 'us_QueryRsPrivAction.do'); },
    //获取消息队列
    GetMessagesQueue: data => { return ExeApi(data, 'mg_PageMessageAction.do'); },
    //修改消息状态
    PutMessagesState: data => { return ExeApi(data, 'sa_UpdateMsgView_batchalterMessageStuts.do'); },
    //删除消息
    DeteleMessage: data => { return ExeApi(data, 'sa_DeleteMessAction_batchRemoveMess.do'); },
    //更新jwt token
    RefreshToken: data => { return ExeApi(data, 'sa_UserLoginInAction_getRefreshToken.do'); }
};
export default publicApi;
